package com.waimai.api.logging;

import java.util.Arrays;
import java.util.List;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

public class APILogAspect {
    
    public void beforeMethod(JoinPoint joinPoint) {
    	String methodName = joinPoint.getSignature().getName();
		List<Object> args = Arrays.asList(joinPoint.getArgs());
    	
        System.out.println("API 请求开始------"+methodName+"----------");  
        System.out.println("参数" + args);
    }  
    
    public void afterReturning(JoinPoint joinPoint, Object result){
		String methodName = joinPoint.getSignature().getName();
		
		System.out.println("API 请求结束------"+methodName+"----------");  
        System.out.println("返回值" + result);
        
        System.out.println("-------------------------------------------------"); 
	}
}
